<style>
img{width:50px;border:none;}
.my_red{color:red;}
.my_green{color:green;}
</style>
<!-- 表示一个成功的或积极的动作 -->
<div class="row">
<a href="{:U('News/index')}"><button type="button" class="btn btn-primary">资讯列表</button></a>
<a href="{:U('News/type')}"><button type="button" class="btn btn-primary">分类列表</button></a>
<a href="{:U('News/news')}"><button type="button" class="btn btn-primary">添加资讯</button></a>
<a href="javascript:void(0)"><button type="button" class="btn btn-primary   active">编辑资讯</button></a>
</div>
<div class="row" style="margin-top:10px;">
 	<form class="form-horizontal" method="post" role="form">
      <div class="form-group">
	      <label for="firstname" class="col-sm-1 control-label">分类</label>
	      <div class="col-sm-2">
	         <select name="tid" id="selected" class="form-control">
	         <volist name="type" id="type">
		         <option value="{$type.id}">{$type.name}</option>
		     </volist>   
	      	 </select>
	      </div>
	   </div>
	   <div class="form-group">
	      <label for="title" class="col-sm-1 control-label">标题</label>
	      <div class="col-sm-10">
	         <input type="text" name="title" class="form-control" id="title" 
	            placeholder="请输入资讯标题(必填)" value="{$data.title}">
	      </div>
	   </div>
	   
	   <div class="form-group">
	      <label for="from" class="col-sm-1 control-label">来源</label>
	      <div class="col-sm-10">
	         <input type="text" class="form-control" name="from" id="from" value="{$data.from}"
	            placeholder="请输入资讯来源(选填)">
	      </div>
	   </div>

		<div class="form-group">
	      <label for="author" class="col-sm-1 control-label">作者</label>
	      <div class="col-sm-10">
	         <input type="text" class="form-control" name="author" id="author" value="{$data.author}"
	            placeholder="请输入作者">
	      </div>
	   </div>

	   <div class="form-group">
	      <label for="tags" class="col-sm-1 control-label">标签</label>
	      <div class="col-sm-10">
	         <input type="text" name="tags" class="form-control" id="tags" 
	            placeholder="为便于SEO优化，建议输入标签，多个标签，以英文逗号分隔开(选填)" value="{$data.value}"/>
	      </div>
	   </div>
		
		<div class="form-group">
	      <label for="desc" class="col-sm-1 control-label">摘要</label>
	      <div class="col-sm-10">
	         <textarea rows="3" name="desc"  id="desc" class="form-control" placeholder="为便于SEO优化，建议输入(选填)">{$data.desc}</textarea>
	      </div>
	   </div>

	  <div class="form-group">
	      <label for="container" class="col-sm-1 control-label">内容</label>
	      <div class="col-sm-10">
	           <!-- 加载编辑器的容器 -->
			    <script id="container" name="content" type="text/plain"></script>
			    <!-- 配置文件 -->
			    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
			    <!-- 编辑器源码文件 -->
			    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
			    <!-- 实例化编辑器 -->
			    <script type="text/javascript">
			        var ue = UE.getEditor('container',{
			        	initialFrameHeight:320,
			        	indentValue:'2em',
			        	autoHeightEnabled:false
			        });
			        ue.ready(function() {
			            //设置编辑器的内容
			            ue.setContent('{$data.content}');
			           /*  //获取html内容，返回: <p>hello</p>
			            var html = ue.getContent();
			            //获取纯文本内容，返回: hello
			            var txt = ue.getContentTxt(); */
			        });
			    </script>
	      </div>
	   </div>
	   
	   <input name="id" value="{$data.id}" type="hidden">
	   
	   <div class="form-group">
	      <div class="col-sm-offset-1 col-sm-10">
	         <button type="button" id="submit_btn" class="btn btn-primary">　确定修改　</button>
	      </div>
	   </div>
	</form>
</div>
<script>
$(document).ready(function(){
	$("#submit_btn").click(function(){
		if($("#title").val()=="" || ue.getContent()==""){
			alert('标题和内容均不能为空');
			return false;
		}else{
			$('form').submit();
		}
		
	});
	var tid="{$data.tid}";
	var selected=$("#selected option");
	$.each(selected,function(){
		if($(this).attr('value')==tid){
			$(this).attr('selected','selected');
		}
	});
	
});
</script>






